/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package br.com.cotec.model;

import java.io.Serializable;

import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToOne;
import javax.persistence.Table;

/**
 *
 * @author magalhaes
 */
@Entity
@Table(name = "logradouro")
@NamedQueries({@NamedQuery(name = "Logradouro.findAll", query = "SELECT l FROM Logradouro l"), 
			   @NamedQuery(name = "Logradouro.findById", query = "SELECT l FROM Logradouro l WHERE l.id = :id"), 
			   @NamedQuery(name = "Logradouro.findByRua", query = "SELECT l FROM Logradouro l WHERE l.rua = :rua"), 
			   @NamedQuery(name = "Logradouro.findByNumero", query = "SELECT l FROM Logradouro l WHERE l.numero = :numero"), 
			   @NamedQuery(name = "Logradouro.findByCep", query = "SELECT l FROM Logradouro l WHERE l.cep = :cep"), 
   			   @NamedQuery(name = "Logradouro.findByTelefoneEmpresa", query = "SELECT l FROM Logradouro l WHERE l.telefoneEmpresa = :telefoneEmpresa"), 
			   @NamedQuery(name = "Logradouro.findByTelefoneCelular", query = "SELECT l FROM Logradouro l WHERE l.telefoneCelular = :telefoneCelular")})
public class Logradouro implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id")
    private Long id;
    @Column(name = "rua", length=45)
    @Basic(optional = false)
    private String rua;
    @Column(name = "numero", length=6)
    @Basic(optional = false)
    private Long numero;
    @Column(name = "bairro", length=45)
    @Basic(optional = false)
    private String bairro;
    @Column(name = "cep", length=10)
    private String cep;
    @Column(name = "telefone_empresa", length=13)
    @Basic(optional = false)
    private String telefoneEmpresa;
    @Column(name = "telefone_celular", length=13)
    private String telefoneCelular;
    @JoinColumn(name = "instituicao", referencedColumnName = "id")
    @OneToOne(optional = false)
    private Instituicao instituicao;
    @JoinColumn(name = "cidade", referencedColumnName = "id")
    @ManyToOne(optional = true, fetch = FetchType.EAGER)
    private Cidade cidade;

    public Logradouro() {
    	this.setCidade(new Cidade());
    }

    public Logradouro(Long id) {
        this.id = id;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getRua() {
        return rua;
    }

    public void setRua(String rua) {
        this.rua = rua;
    }

    public Long getNumero() {
        return numero;
    }

    public void setNumero(Long numero) {
        this.numero = numero;
    }

    public String getCep() {
        return cep;
    }

    public String getBairro() {
		return bairro;
	}

	public void setBairro(String bairro) {
		this.bairro = bairro;
	}

	public void setCep(String cep) {
        this.cep = cep;
    }

    public String getTelefoneEmpresa() {
        return telefoneEmpresa;
    }

    public void setTelefoneEmpresa(String telefoneEmpresa) {
        this.telefoneEmpresa = telefoneEmpresa;
    }

    public String getTelefoneCelular() {
        return telefoneCelular;
    }

    public void setTelefoneCelular(String telefoneCelular) {
        this.telefoneCelular = telefoneCelular;
    }

    public Instituicao getInstituicao() {
        return instituicao;
    }

    public void setInstituicao(Instituicao instituicao) {
        this.instituicao = instituicao;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    public Cidade getCidade() {
		return cidade;
	}

	public void setCidade(Cidade cidade) {
		this.cidade = cidade;
	}

	@Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Logradouro)) {
            return false;
        }
        Logradouro other = (Logradouro) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "br.com.cotec.model.Logradouro[id=" + id + "]";
    }

}
